# fwrite_csv: 保存 csv 文件 ----
fwrite_csv <- function(x, file, 
                       col.names = TRUE, row.names = TRUE, 
                       nThread = data.table::getDTthreads(verbose), 
                       verbose = getOption("datatable.verbose", FALSE)) {
  # data.frame
  buffMB <- as.integer((object.size(x)/1e+6)/nThread)
  buffMB <- ifelse(buffMB == 0, 1, buffMB)
  
  sep <- switch(
    stringr::str_sub(file, -3, -1), 
    tsv='\t', 
    csv=',', 
    ",")
  
  data.table::fwrite(x=x, file=file, 
                     col.names=col.names, row.names=row.names, 
                     buffMB=buffMB, nThread = nThread, 
                     sep=sep)
}
